package com.itheima.pattern.iterator;

public class Client {
    public static void main(String[] args) {
        // 创建聚合对象
        StudentAggregateImpl aggregate = new StudentAggregateImpl();
        aggregate.addStudent(new Student("小王", "001"));
        aggregate.addStudent(new Student("小张", "002"));
        aggregate.addStudent(new Student("小李", "003"));
        aggregate.addStudent(new Student("小赵", "004"));

        StudentIterator iterator = aggregate.getStudentIterator();
        while (iterator.hasNext()) {
            Student student = iterator.next();
            System.out.println(student.getName() + " " + student.getNumber());
        }
    }
}
